package com.zzb.framework.mail.service;

import com.alibaba.fastjson.JSON;
import com.zzb.framework.mail.dao.MailDAO;
import com.zzb.framework.mail.entity.Mail;
import com.zzb.framework.role.entity.IUser;
import com.zzb.framework.common.BaseResponse;
import com.zzb.framework.common.BaseService;
import com.zzb.framework.common.ServiceException;
import com.zzb.framework.validator.annotation.ValidatorEnabled;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 邮件 service类
*/
@Service
public class MailService extends BaseService<MailDAO,Mail> {
    private static final Logger logger = LoggerFactory.getLogger(MailService.class);
    @Autowired
    private MailDAO mailDAO;
    @Override
    public MailDAO getDAO() {
        return mailDAO;
    }
    /**删除邮件*/
    public BaseResponse deleteMail(String id,IUser operate) throws ServiceException{
        //TODO
        return deleteById(id);
    }
    /**保存邮件*/
    @ValidatorEnabled
    public BaseResponse<Mail> saveMail(Mail mail, IUser operator) throws ServiceException{
        logger.info("正在保存邮件["+ JSON.toJSONString(mail)+"]["+JSON.toJSONString(operator)+"]");
        //TODO
        return insertOrUpdate(mail,operator);
    }
}
